<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 12">
<meta name=Originator content="Microsoft Word 12">
<link rel=File-List href="oop_files/filelist.xml">
<title>C++Script Manual</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>calum</o:Author>
  <o:LastAuthor>Calum Grant</o:LastAuthor>
  <o:Revision>12</o:Revision>
  <o:TotalTime>6</o:TotalTime>
  <o:Created>2008-12-18T21:59:00Z</o:Created>
  <o:LastSaved>2008-12-19T13:19:00Z</o:LastSaved>
  <o:Pages>3</o:Pages>
  <o:Words>1504</o:Words>
  <o:Characters>8573</o:Characters>
  <o:Lines>71</o:Lines>
  <o:Paragraphs>20</o:Paragraphs>
  <o:CharactersWithSpaces>10057</o:CharactersWithSpaces>
  <o:Version>12.00</o:Version>
 </o:DocumentProperties>
</xml><![endif]-->
<link rel=themeData href="oop_files/themedata.thmx">
<link rel=colorSchemeMapping href="oop_files/colorschememapping.xml">
<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:TrackMoves>false</w:TrackMoves>
  <w:TrackFormatting/>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:DoNotPromoteQF/>
  <w:LidThemeOther>EN-GB</w:LidThemeOther>
  <w:LidThemeAsian>X-NONE</w:LidThemeAsian>
  <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
  <w:Compatibility>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:SplitPgBreakAndParaMark/>
   <w:DontVertAlignCellWithSp/>
   <w:DontBreakConstrainedForcedTables/>
   <w:DontVertAlignInTxbx/>
   <w:Word11KerningPairs/>
   <w:CachedColBalance/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
  <m:mathPr>
   <m:mathFont m:val="Cambria Math"/>
   <m:brkBin m:val="before"/>
   <m:brkBinSub m:val="&#45;-"/>
   <m:smallFrac m:val="off"/>
   <m:dispDef/>
   <m:lMargin m:val="0"/>
   <m:rMargin m:val="0"/>
   <m:defJc m:val="centerGroup"/>
   <m:wrapIndent m:val="1440"/>
   <m:intLim m:val="subSup"/>
   <m:naryLim m:val="undOvr"/>
  </m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
  DefSemiHidden="true" DefQFormat="false" DefPriority="99"
  LatentStyleCount="267">
  <w:LsdException Locked="false" Priority="0" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="heading 2"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 1"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 2"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 3"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 4"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 5"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 6"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 7"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 8"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 9"/>
  <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
  <w:LsdException Locked="false" Priority="10" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Title"/>
  <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
  <w:LsdException Locked="false" Priority="11" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
  <w:LsdException Locked="false" Priority="22" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
  <w:LsdException Locked="false" Priority="20" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
  <w:LsdException Locked="false" Priority="59" SemiHidden="false"
   UnhideWhenUsed="false" Name="Table Grid"/>
  <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
  <w:LsdException Locked="false" Priority="1" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 1"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
  <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
  <w:LsdException Locked="false" Priority="34" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
  <w:LsdException Locked="false" Priority="29" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
  <w:LsdException Locked="false" Priority="30" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 1"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 2"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 2"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 3"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 3"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 4"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 4"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 5"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 5"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 6"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 6"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
  <w:LsdException Locked="false" Priority="19" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
  <w:LsdException Locked="false" Priority="21" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
  <w:LsdException Locked="false" Priority="31" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
  <w:LsdException Locked="false" Priority="32" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
  <w:LsdException Locked="false" Priority="33" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
  <w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
  <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
 </w:LatentStyles>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;
	mso-font-charset:1;
	mso-generic-font-family:roman;
	mso-font-format:other;
	mso-font-pitch:variable;
	mso-font-signature:0 0 0 0 0 0;}
@font-face
	{font-family:Cambria;
	panose-1:2 4 5 3 5 4 6 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:roman;
	mso-font-pitch:variable;
	mso-font-signature:-1610611985 1073741899 0 0 159 0;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:-1610611985 1073750139 0 0 159 0;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:modern;
	mso-font-pitch:fixed;
	mso-font-signature:-1610611985 1073750091 0 0 159 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";}
h1
	{mso-style-priority:9;
	mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-link:"Heading 1 Char";
	mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	mso-outline-level:1;
	font-size:24.0pt;
	font-family:"Cambria","serif";
	mso-ascii-font-family:Cambria;
	mso-ascii-theme-font:major-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Cambria;
	mso-hansi-theme-font:major-latin;
	font-weight:bold;}
h2
	{mso-style-priority:9;
	mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-link:"Heading 2 Char";
	mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	mso-outline-level:2;
	font-size:18.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	font-weight:bold;}
a:link, span.MsoHyperlink
	{mso-style-noshow:yes;
	mso-style-priority:99;
	color:blue;
	text-decoration:underline;
	text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-noshow:yes;
	mso-style-priority:99;
	color:purple;
	text-decoration:underline;
	text-underline:single;}
p
	{mso-style-noshow:yes;
	mso-style-priority:99;
	mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";}
pre
	{mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-link:"HTML Preformatted Char";
	margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
	font-size:10.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;}
span.Heading1Char
	{mso-style-name:"Heading 1 Char";
	mso-style-priority:9;
	mso-style-unhide:no;
	mso-style-locked:yes;
	mso-style-link:"Heading 1";
	mso-ansi-font-size:24.0pt;
	mso-bidi-font-size:24.0pt;
	font-family:"Cambria","serif";
	mso-ascii-font-family:Cambria;
	mso-ascii-theme-font:major-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Cambria;
	mso-hansi-theme-font:major-latin;
	mso-font-kerning:18.0pt;
	font-weight:bold;}
span.Heading2Char
	{mso-style-name:"Heading 2 Char";
	mso-style-noshow:yes;
	mso-style-priority:9;
	mso-style-unhide:no;
	mso-style-locked:yes;
	mso-style-link:"Heading 2";
	mso-ansi-font-size:13.0pt;
	mso-bidi-font-size:13.0pt;
	font-family:"Cambria","serif";
	mso-ascii-font-family:Cambria;
	mso-ascii-theme-font:major-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:major-fareast;
	mso-hansi-font-family:Cambria;
	mso-hansi-theme-font:major-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:major-bidi;
	color:#4F81BD;
	mso-themecolor:accent1;
	font-weight:bold;}
span.HTMLPreformattedChar
	{mso-style-name:"HTML Preformatted Char";
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-unhide:no;
	mso-style-locked:yes;
	mso-style-link:"HTML Preformatted";
	font-family:Consolas;
	mso-ascii-font-family:Consolas;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Consolas;}
.MsoChpDefault
	{mso-style-type:export-only;
	mso-default-props:yes;
	font-size:10.0pt;
	mso-ansi-font-size:10.0pt;
	mso-bidi-font-size:10.0pt;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;
	mso-header-margin:35.4pt;
	mso-footer-margin:35.4pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
 /* List Definitions */
 @list l0
	{mso-list-id:328098001;
	mso-list-template-ids:-587532962;}
@list l0:level1
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:36.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	mso-ansi-font-size:10.0pt;
	font-family:Symbol;}
@list l1
	{mso-list-id:1390420168;
	mso-list-template-ids:-1517907466;}
@list l1:level1
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:36.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	mso-ansi-font-size:10.0pt;
	font-family:Symbol;}
@list l1:level2
	{mso-level-tab-stop:72.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level3
	{mso-level-tab-stop:108.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level4
	{mso-level-tab-stop:144.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level5
	{mso-level-tab-stop:180.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level6
	{mso-level-tab-stop:216.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level7
	{mso-level-tab-stop:252.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level8
	{mso-level-tab-stop:288.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level9
	{mso-level-tab-stop:324.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-qformat:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman","serif";}
</style>
<![endif]--><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="3074"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-GB link=blue vlink=purple style='tab-interval:36.0pt'>

<div class=Section1>

<h1><span style='mso-fareast-font-family:"Times New Roman"'>Object-Oriented
Programming<o:p></o:p></span></h1>

<p>C++Script provides an alternative way to write object-oriented
programs.&nbsp; You can of course use C++ classes if you prefer.</p>

<p>C++Script's OOP is quite unusual because objects don't have types in the
traditional sense.&nbsp; In order to create an object, you just call a function
which builds up the object for you.&nbsp; This is simple but also really
flexible, giving factories, brokers, inheritance, closures and nested classes
out of just a few simple concepts.</p>

<h2><span style='mso-fareast-font-family:"Times New Roman"'>Objects as
containers<o:p></o:p></span></h2>

<p>You can create an object using the <i>object()</i> function, and add members
and methods to it manually.&nbsp; An object is just a container of name-value
pairs.&nbsp; As an additional restriction, members of objects must be strings
(you could use a <i>map()</i> if you wanted to lift this restriction).&nbsp;
You would normally write a &quot;constructor function&quot; to construct
objects of a particular type.&nbsp; e.g. (<a href="object1.cpp">object1.cpp</a>)</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>#include &lt;cppscript&gt;</pre><pre><o:p>&nbsp;</o:p></pre><pre>var create_a_tree(var species, var height) // Constructor function</pre><pre>{</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>var tree = object(); </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;</span>tree[&quot;species&quot;] = species;</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>tree[&quot;height&quot;] = height;</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>return tree;</pre><pre>}</pre><pre><o:p>&nbsp;</o:p></pre><pre>var script_main(var)</pre><pre>{</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>var oak = create_a_tree(&quot;oak&quot;, 12.2), maple = create_a_tree(&quot;maple&quot;, 15.0);</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>writeln( &quot;The height of the oak is &quot; + oak[&quot;height&quot;] );</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>return 0;</pre><pre>}</pre></blockquote>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>You
can specify a class name to the <i>object()</i> function, which can then be
queried using <i>var::class_name()</i>.&nbsp; The class name is useful mainly
for debugging.</p>

<h2 style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='mso-fareast-font-family:"Times New Roman"'>Calling methods<o:p></o:p></span></h2>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>A
method is a function that is contained in an object.&nbsp; From the caller's
perspective, a method is a functor.&nbsp; Recall that a functor is a <i>var</i>
that contains a function.&nbsp; Suppose you had an object <i>foo,</i> and you
wanted to call the <i>bar </i>method on the object.&nbsp; You call the method
using</p>

<pre style='margin-left:30.0pt'>var foo;</pre><pre style='margin-left:30.0pt'>foo[&quot;bar&quot;]();</pre>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><i>foo[&quot;bar&quot;]</i>
means the <i>&quot;bar&quot;</i> member of the <i>foo </i>object, and the ()
means call the <i>var</i> as a function.&nbsp; You can naturally pass arguments
to the method, e.g.</p>

<pre style='margin-left:30.0pt'>foo[&quot;bar&quot;](1,2,3);</pre>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>etc.</p>

<h2 style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='mso-fareast-font-family:"Times New Roman"'>Defining methods<o:p></o:p></span></h2>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>Methods
are defined by assigning functors to members of the object.&nbsp; There is a
little detail which is that functors are often &quot;bound&quot; (the
equivalent of a non-static member function in C++) to an object.&nbsp; In fact
when functions are assigned to members of objects, the first argument of the
function is implicitly bound.&nbsp; e.g. (<a href="methods.cpp">methods.cpp</a>)</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'>

<p class=MsoNormal style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman"'>#include
&lt;cppscript&gt;<br>
<br>
var growth_rate(var tree) { return
tree[&quot;height&quot;]/tree[&quot;age&quot;]; }<br>
<br>
void grow(var tree, var height) { tree[&quot;height&quot;] += height; }<br>
<br>
var tree(var species, var height, var age)<br>
{<br>
&nbsp;&nbsp; &nbsp;var tree = object();<br>
&nbsp;&nbsp; &nbsp;tree[&quot;species&quot;] = species;<br>
&nbsp;&nbsp; &nbsp;tree[&quot;height&quot;] = height;<br>
&nbsp;&nbsp; &nbsp;tree[&quot;age&quot;] = age;<br>
&nbsp;&nbsp; &nbsp;tree[&quot;growth_rate&quot;] = growth_rate; // Equivalent
to bind(growth_rate, tree);<br>
&nbsp;&nbsp; &nbsp;tree[&quot;grow&quot;] = grow; // Equivalent to bind(grow,
tree)<br>
&nbsp;&nbsp; &nbsp;return tree;<br>
}<br>
<br>
var script_main(var args)<br>
{<br>
&nbsp;&nbsp; &nbsp;var oak = tree(&quot;oak&quot;, 10, 2);<br>
&nbsp;&nbsp; &nbsp;writeln( oak[&quot;growth_rate&quot;]() ); // 5<br>
&nbsp;&nbsp; &nbsp;oak[&quot;grow&quot;](2);<br>
&nbsp;&nbsp; &nbsp;writeln( oak[&quot;growth_rate&quot;]() ); // 6<br>
&nbsp;&nbsp; &nbsp;return 0;<br>
}</span><span style='font-size:10.0pt;mso-fareast-font-family:"Times New Roman"'><o:p></o:p></span></p>

</blockquote>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>Non-bound
member functions (equivalent to static methods in C++) can be assigned via a <i>var
</i>which creates an unbound functor.&nbsp; e.g.</p>

<pre style='margin-left:30.0pt'><span style='mso-spacerun:yes'>&nbsp;</span>tree[&quot;x&quot;] = var(grow);</pre>

<h2 style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='mso-fareast-font-family:"Times New Roman"'>Binding and closures<o:p></o:p></span></h2>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>The
previous example showed how a function was bound to an object through the line</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>tree[&quot;grow&quot;] = grow;</pre></blockquote>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>What's
happening is that the value assigned to the <i>&quot;grow&quot;</i> member of
tree is <i>bind(growth_rate, tree)</i>.&nbsp; You can actually write</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>tree[&quot;grow&quot;] = bind(grow, tree);</pre></blockquote>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>which
has the same effect.&nbsp; What's a little unexpected is that the bound
function can be used independently of the object it is bound to:</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>var g = oak[&quot;grow&quot;];</pre><pre>g(2); // grow the oak by 2</pre></blockquote>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>The
variable <i>g</i> (as well as<i> oak[&quot;grow&quot;]</i>) is a closure,
because the first argument (tree) of the <i>grow()</i> function is
&quot;bound&quot; to a particular object.</p>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>The
<i>bind()</i> function works behind the scenes to create closures every time
you assign a function to an object.&nbsp; You can also use the <i>bind()</i>
function explicitly, and bind any number of arguments to a function.&nbsp;<i>
bind()</i> takes a functor as its first argument, and binds the number of
arguments specified.&nbsp; E.g.</p>

<pre style='margin-left:30.0pt'>var grow_oak_by_1 = bind(oak[&quot;grow&quot;], 1); </pre>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>creates
a <i>var </i>with arguments to <i>grow()</i> function bound with values <i>oak</i>,
and <i>1</i>.</p>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>Note
that the following are equivalent:</p>

<pre style='margin-left:30.0pt'>bind( oak[&quot;grow&quot;], 1 );</pre><pre
style='margin-left:30.0pt'>bind( grow, oak, 1 );</pre><pre style='margin-left:
30.0pt'>bind( bind(grow, oak), 1 );</pre>

<h2 style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='mso-fareast-font-family:"Times New Roman"'>Inheritance<o:p></o:p></span></h2>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>Supposing
we wanted to add some more types of tree.&nbsp; We could imagine copying and
pasting the tree constructor function into two more constructor functions: <i>oak()</i>
and <i>maple()</i>, and tweaking the species.&nbsp; That would be poor
style.&nbsp; Instead you should call the <i>tree()</i> function from the <i>oak()</i>
function and the <i>maple()</i> function as follows: </p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>// Constructor for an oak</pre><pre>var oak(var height, var age) { return tree(&quot;oak&quot;, height, age); }</pre><pre><o:p>&nbsp;</o:p></pre><pre>// Constructor for a maple</pre><pre>var maple(var height, var age) { return tree(&quot;maple&quot;, height, age); }</pre></blockquote>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>The
astute reader will notice that we already have all the tools needed for
inheritance.&nbsp; In effect, the <i>oak()</i> and <i>maple()</i> functions
creates a specialisation of tree.&nbsp; We could make the specialization as
interesting as we like:</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>var maple_grow(var maple, var height) </pre><pre>{ </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;</span>maple[&quot;height&quot;] += 2*height; // They grow really fast</pre><pre>}</pre><pre><o:p>&nbsp;</o:p></pre><pre><span
lang=SV style='mso-ansi-language:SV'>var maple(var height, var age)<o:p></o:p></span></pre><pre>{</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>var maple = tree(&quot;maple&quot;, height, age);</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>maple[&quot;grow&quot;] = maple_grow; // Override method</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>maple[&quot;colour&quot;] = &quot;red&quot;; // Add a member</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>return maple;</pre><pre>}</pre></blockquote>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>The
<i>var::extend()</i> method provides a convenient shorthand for this type of
function.&nbsp; <i>extend()</i> takes a sequence of name-value pairs which is
assigns to the object.&nbsp; The <i>tree()</i> and <i>maple()</i> functions
could then be written:</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre><span lang=SV
style='mso-ansi-language:SV'>var tree(var species, var height, var age)<o:p></o:p></span></pre><pre>{</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>return object().extend </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>(&quot;species&quot;, species)</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;height&quot;, height)</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;age&quot;, age)</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;grow&quot;, grow) </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>(&quot;growth_rate&quot;, growth_rate);</pre><pre>}</pre><pre><o:p>&nbsp;</o:p></pre><pre><span
lang=SV style='mso-ansi-language:SV'>var maple(var height, var age)<o:p></o:p></span></pre><pre>{</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>return tree(&quot;maple&quot;, height, age).extend</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;grow&quot;, maple_grow)</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;colour&quot;, &quot;yellow&quot;);</pre><pre>}</pre></blockquote>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>Multiple
inheritance can be handled using the += operator to merge objects, or you can
just supply a base object to the constructor function.</p>

<h2 style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='mso-fareast-font-family:"Times New Roman"'>Private variables<o:p></o:p></span></h2>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>There
isn't a built-in mechanism to make members private.&nbsp; The simplest way to
do this is to give members special names, and then trust that client code won't
modify your data. For example</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>var counter()</pre><pre>{</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>return object().extend</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;private_value&quot;, 0)</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;inc&quot;, counter_inc)</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;reset&quot;, counter_reset)</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;get&quot;, counter_get);</pre><pre>}</pre></blockquote>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>This
has the drawback of being slightly inelegant, and clients could still
accidentally modify your internals. If you are really paranoid therefore, you
can create a &quot;hidden object&quot; which lies behind your interface, as
follows: </p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>var counter()</pre><pre>{</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>var hidden = object().extend</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;private_value&quot;, 0)</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;inc&quot;, counter_inc)</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;reset&quot;, counter_reset)</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;get&quot;, counter_get);</pre><pre><o:p>&nbsp;</o:p></pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>return object().extend</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;inc&quot;, hidden[&quot;inc&quot;])</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;reset&quot;, hidden[&quot;reset&quot;])</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;get&quot;, hidden[&quot;get&quot;]); </pre><pre>}</pre></blockquote>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>There
is now no way that client code can access the <i>&quot;private_value&quot;</i>
member of the counter. &nbsp;A different approach is to clone the object, which
does not rebind the member functions. &nbsp;As a result, client code can modify
the <i>&quot;private_value&quot;</i> member as much as they want, but all of
the methods are still bound to their original object, which is a different
variable. &nbsp;This has the effect of &quot;sealing/finalizing&quot; the
object.</p>

<pre style='margin-left:30.0pt'>var counter()</pre><pre style='margin-left:
30.0pt'>{</pre><pre style='margin-left:30.0pt'><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>return +object().extend</pre><pre
style='margin-left:30.0pt'><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;private_value&quot;, 0)</pre><pre
style='margin-left:30.0pt'><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;inc&quot;, counter_inc)</pre><pre
style='margin-left:30.0pt'><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;reset&quot;, counter_reset)</pre><pre
style='margin-left:30.0pt'><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;get&quot;, counter_get);</pre><pre
style='margin-left:30.0pt'>}</pre>

<h2 style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='mso-fareast-font-family:"Times New Roman"'>Factories<o:p></o:p></span></h2>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>The
inheritance example suggests that constructor functions (e.g. <i>tree()</i>, <i>maple()</i>,
<i>oak()</i>) are a kind of &quot;type&quot;.&nbsp; This analogy might be true
in the basic case, but functions are much more like factories.&nbsp; The point
is that the caller does not know the exact type of what is returned, only that
an object is returned matching the needs of the caller.&nbsp; Factories could
quite easily be methods, providing context for the construction.</p>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>Contrast
this with the &quot;new X&quot; approach in strongly-typed languages.&nbsp;
This is really inflexible because you are forcing the system to create a
particular object, when a factory or broker is usually preferable.</p>

<h2 style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='mso-fareast-font-family:"Times New Roman"'>Dispatchers<o:p></o:p></span></h2>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>A
&quot;dispatcher&quot; is an object which lets you define the <i>var</i>
methods, much like you can overload operators in C++.<b><o:p></o:p></b></p>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>Dispatchers
are created using the <i>dispatcher()</i> function, which accepts an object
which contains methods for the functions you wish to implement.</p>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>The
following example (<a href="dispatcher.cpp">dispatcher.cpp</a>) implements the <i>&quot;get_member</i>&quot;
and &quot;<i>set_member&quot;</i> methods, to create an object with special
behaviour when you get and set members of the object:</p>

<pre style='margin-left:30.0pt'>#include &lt;cppscript&gt;</pre><pre
style='margin-left:30.0pt'><o:p>&nbsp;</o:p></pre><pre style='margin-left:30.0pt'>var counter_get(var c) { return c[&quot;value&quot;]++; }</pre><pre
style='margin-left:30.0pt'><o:p>&nbsp;</o:p></pre><pre style='margin-left:30.0pt'>var counter(var value) </pre><pre
style='margin-left:30.0pt'>{</pre><pre style='margin-left:30.0pt'><span
style='mso-tab-count:1'>&nbsp;&nbsp; </span>return object(&quot;counter&quot;).extend</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;value&quot;, value)</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;get&quot;, counter_get);</pre><pre
style='margin-left:30.0pt'>}</pre><pre style='margin-left:30.0pt'><o:p>&nbsp;</o:p></pre><pre
style='margin-left:30.0pt'>var multicounter_get(var multicounter, var counter_name)</pre><pre
style='margin-left:30.0pt'>{</pre><pre style='margin-left:30.0pt'><span
style='mso-tab-count:1'>&nbsp;&nbsp; </span>return multicounter[&quot;counters&quot;][counter_name][&quot;get&quot;]();</pre><pre
style='margin-left:30.0pt'>}</pre><pre style='margin-left:30.0pt'><o:p>&nbsp;</o:p></pre><pre
style='margin-left:30.0pt'>void multicounter_set(var multicounter, var counter_name, var value)</pre><pre
style='margin-left:30.0pt'>{</pre><pre style='margin-left:30.0pt'><span
style='mso-tab-count:1'>&nbsp;&nbsp; </span>multicounter[&quot;counters&quot;][counter_name] = counter(value);</pre><pre
style='margin-left:30.0pt'>}</pre><pre style='margin-left:30.0pt'><o:p>&nbsp;</o:p></pre><pre
style='margin-left:30.0pt'>var multicounter()</pre><pre style='margin-left:
30.0pt'>{</pre><pre style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>return dispatcher( </pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>object(&quot;multicounter&quot;).extend</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;counters&quot;, map())</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;get_member&quot;, multicounter_get)</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;set_member&quot;, multicounter_set)</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>);</pre><pre
style='margin-left:30.0pt'>}</pre><pre style='margin-left:30.0pt'><o:p>&nbsp;</o:p></pre><pre
style='margin-left:30.0pt'>var script_main(var)</pre><pre style='margin-left:
30.0pt'>{</pre><pre style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>var counters = multicounter();</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>counters[&quot;c1&quot;] = 0;</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>counters[&quot;c2&quot;] = 10;</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>writeln( counters[&quot;c1&quot;] );<span style='mso-spacerun:yes'>&nbsp; </span>// 0</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>writeln( counters[&quot;c2&quot;] );<span style='mso-spacerun:yes'>&nbsp; </span>// 10</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>writeln( counters[&quot;c1&quot;] );<span style='mso-spacerun:yes'>&nbsp; </span>// 1</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>writeln( counters[&quot;c2&quot;] );<span style='mso-spacerun:yes'>&nbsp; </span>// 11</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>return 0;</pre><pre
style='margin-left:30.0pt'>}</pre>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'>The
following methods can be implemented on the dispatcher:<b><o:p></o:p></b></p>

<ul type=disc>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>&quot;get_member&quot;, &quot;set_member&quot;,
     &quot;class_name&quot;, &quot;call&quot;, &quot;as_string&quot;,
     &quot;as_int&quot;, &quot;as_double&quot;, &quot;as_bool&quot;,
     &quot;size&quot;, &quot;resize&quot;, &quot;empty&quot;,
     &quot;enumerator&quot;, &quot;reverse_enumerator&quot;, &quot;keys&quot;,
     &quot;values&quot;, &quot;insert&quot;, &quot;reserve&quot;,
     &quot;capacity&quot;, &quot;push_front&quot;, &quot;pop_front&quot;,
     &quot;push_back&quot;, &quot;pop_back&quot;, &quot;back&quot;,
     &quot;front&quot;, &quot;clear&quot;, &quot;contains&quot;,
     &quot;erase&quot;, &quot;clone&quot;, &quot;key&quot;, &quot;value&quot;,
     &quot;deref&quot;, &quot;++&quot;, &quot;--&quot;, &quot;+&quot;,
     &quot;-&quot;, &quot;*&quot;, &quot;/&quot;, &quot;%&quot;,
     &quot;&lt;&lt;&quot;, &quot;&gt;&gt;&quot;,&nbsp; &quot;&amp;&quot;,
     &quot;|&quot;, &quot;^&quot;, &quot;~&quot;, &quot;+=&quot;,
     &quot;-=&quot;, &quot;*=&quot;, &quot;/=&quot;, &quot;%=&quot;,
     &quot;&lt;&lt;=&quot;, &quot;&gt;&gt;=&quot;, &quot;&amp;=&quot;,
     &quot;|=&quot;, &quot;^=&quot;</span></i><span style='mso-fareast-font-family:
     "Times New Roman"'><o:p></o:p></span></li>
</ul>

</div>

</body>

</html>
